#include "message.h"

Message::Message()
{

    messageOpen = false;

    xPos = 300;
    yPos = 50;

    boxWidth = 350;
    boxHeight = 75;

    fontSize = 20;

    messageRect.setSize(sf::Vector2f(boxWidth,boxHeight));
    messageRect.setPosition(xPos,yPos);
    messageRect.setFillColor(sf::Color::Black);
    messageRect.setOutlineThickness(3);
    messageRect.setOutlineColor(sf::Color::White);

    font.loadFromFile("resources/arial.ttf");

    headerText.setString("Man: ");
    headerText.setFont(font);
    headerText.setCharacterSize(fontSize);
    //headerText.setStyle(sf::Text::Bold);
    headerText.setColor(sf::Color::Green);
    headerText.setPosition(xPos + 75, yPos);

    setText("Where am I?");
    messageText.setFont(font);
    messageText.setCharacterSize(fontSize);
    //messageText.setStyle(sf::Text::Bold);
    messageText.setColor(sf::Color::White);
    messageText.setPosition(xPos + 100,yPos + 20);

    loadTexture("resources/messageSpriteSheet.png");

    messageSprite.setPosition(xPos + 5, yPos +5);
    messageSprite.setTextureRect(sf::IntRect(0,0,64,64));
    messageSprite.setTexture(messageTexture);

    messageReturn.setPosition(xPos + 305, yPos +50);
    messageReturn.setTextureRect(sf::IntRect(64,0,64,25));
    messageReturn.setTexture(messageTexture);

}

Message::~Message()
{
    //dtor
}

void Message::Render(sf::RenderWindow& window){

    if(messageOpen){
        window.draw(messageRect);
        window.draw(messageSprite);
        window.draw(messageReturn);
        window.draw(messageText);
        window.draw(headerText);
    }

}

void Message::setText(std::string str){
    messageText.setString(str);
    toggleState();
}

bool Message::loadTexture(std::string filename){

    if (!messageTexture.loadFromFile(filename)){
        std::cout << "Texture did not load";
        return false;
    }
    return true;
}

void Message::toggleState(){
    messageOpen = !messageOpen;
}
